import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
import { ValidationPipe } from './pipes/validate.pipe';
import { HttpExceptionFilter } from './filters/http-exception.filter';
import { GetStudentsQueryParseIntPipe } from './students/pipes/get-students-query-parse-int.pipe';
import { GetStudentsQueryDto } from './students/dto/get-students-query.dto';

declare const module: any;

async function bootstrap() {
  const app = await NestFactory.create(AppModule);
  app.useGlobalPipes(new GetStudentsQueryParseIntPipe([GetStudentsQueryDto]));
  app.useGlobalPipes(new ValidationPipe());
  app.useGlobalFilters(new HttpExceptionFilter());
  await app.listen(3000);

  if (module.hot) {
    module.hot.accept();
    module.hot.dispose(() => app.close());
  }
}
bootstrap();
